package chapter3.No3_1_等待和通知机制.k通过管道进行线程间通信_字节流;

import java.io.IOException;
import java.io.PipedInputStream;

/**
 * Created by Administrator on 2016/11/19.
 */
public class ReadData {

    public void readMethod(PipedInputStream pis) {
        try {
            byte[] byteArray = new byte[20];
            int readLength = pis.read(byteArray);
            while (readLength != -1) {
                String readValue = new String(byteArray, 0, readLength);
                System.out.println("读取：" + readValue);
                readLength = pis.read(byteArray);
            }
            pis.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
